<template>
	<view class="container">
		<view class="header">
			<view class="title">易联通达智能分拣系统</view>
			<text class="info">操作员: 6500348862 | 供应包号: 11 | 车间ID: 38549773311223 | 登录时间: 2012/12/12 11:20:35</text>
			<button @click="confirmLogout" class="btn-logout">退出登录</button>
		</view>

		<view class="main">
			<view class="card">
				<text class="card-title">手动输入条码</text>
				<input v-model="barcode" placeholder="请输入条码" class="inputBarcode" />
				<button @click="submitBarcode" class="btn-submit">提交条码</button>
			</view>

			<view class="card">
				<text class="card-title">包裹扫描信息:</text>
				<view class="package-info">
					<text>包裹单号: 385497733094209</text>
				</view>
			</view>

			<view class="card">
				<text class="card-title">上架点:</text>
				<view class="package-info">
					<text>等待上架...</text>
				</view>
			</view>

			<view class="card button-group">
				<button @click="endShelf" class="btn-end">结束上架</button>
				<button @click="cancelBarcode" class="btn-cancel">取消上架条码</button>
			</view>

			<view class="card">
				<text class="card-title">交互信息列表</text>
				<view class="list-header">
					<text>时间</text>
					<text>操作</text>
					<text>信息</text>
					<text>状态</text>
				</view>
				<view class="list-item" v-for="(item, index) in interactionData" :key="index">
					<text>{{ item.time }}</text>
					<text>{{ item.action }}</text>
					<text>{{ item.info }}</text>
					<text class="status-success">{{ item.status }}</text>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
export default {
	data() {
		return {
			barcode: '',
			interactionData: [
				{
					time: '2024/12/26 14:58:39',
					action: '读取条码',
					info: '货物放置在上架点 123456789',
					status: '成功'
				},
				// 添加更多数据项
			]
		};
	},
	methods: {
		confirmLogout() {
			uni.showModal({
				title: '确认退出',
				content: '您确定要退出登录吗？',
				success: (res) => {
					if (res.confirm) {
						this.logout();
					}
				}
			});
		},
		logout() {
			uni.showToast({
				title: '退出登录',
				icon: 'none'
			});
			// 逻辑处理
		},
		submitBarcode() {
			if (this.barcode.trim() === '') {
				uni.showToast({
					title: '请输入有效的条码',
					icon: 'none'
				});
				return;
			}
			uni.showToast({
				title: `条码 ${this.barcode} 已提交`,
				icon: 'none'
			});
			this.barcode = ''; // 清空输入框
		},
		endShelf() {
			uni.showToast({
				title: '结束上架',
				icon: 'none'
			});
			// 逻辑处理
		},
		cancelBarcode() {
			uni.showToast({
				title: '取消上架条码',
				icon: 'none'
			});
			// 逻辑处理
		}
	}
};
</script>

<style>
.container {
	display: flex;
	flex-direction: column;
	height: 100vh;
	background-color: #f5f5f5;
	padding: 20rpx;
}

.header {
	background-color: #007aff;
	color: #fff;
	padding: 30rpx;
	text-align: center;
	border-radius: 10rpx;
	margin-bottom: 20rpx;
}

.title {
	font-size: 40rpx;
	font-weight: bold;
}

.info {
	font-size: 28rpx;
	margin-top: 10rpx;
}

.btn-logout {
	margin-top: 20rpx;
	background-color: #ff3b30;
	color: #fff;
	padding: 10rpx 30rpx;
	border-radius: 10rpx;
	font-size: 28rpx;
}

.main {
	flex: 1;
	display: flex;
	flex-direction: column;
	gap: 20rpx;
}

.card {
	background-color: #fff;
	padding: 30rpx;
	border-radius: 10rpx;
	box-shadow: 0 4rpx 16rpx rgba(0, 0, 0, 0.1);
}

.card-title {
	font-size: 32rpx;
	font-weight: bold;
	margin-bottom: 20rpx;
}

.package-info text {
	display: block;
	margin-bottom: 10rpx;
}

.inputBarcode {
	padding: 20rpx;
	margin-bottom: 20rpx;
	border: 1rpx solid #ddd;
	border-radius: 10rpx;
	font-size: 28rpx;
	margin-top: 10rpx;
}

.btn-submit {
	background-color: #007aff;
	color: #fff;
	padding: 15rpx;
	border-radius: 10rpx;
	font-size: 28rpx;
	text-align: center;
}

.button-group {
	display: flex;
	/* flex-direction: column; */
	gap: 20rpx;
}

.btn-end,
.btn-cancel {
	padding: 20rpx;
	font-size: 28rpx;
	border-radius: 10rpx;
	color: #fff;
	width: 50%;
	text-align: center;
}

.btn-end {
	background-color: #ff3b30;
}

.btn-cancel {
	background-color: #ff9500;
}

.list-header,
.list-item {
	display: flex;
	justify-content: space-between;
	padding: 10rpx 0;
}

.list-header {
	font-weight: bold;
	border-bottom: 1rpx solid #ddd;
}

.status-success {
	color: green;
}
</style>